/**
 * 
 */
package net.homelinux.ajay.net.ondisk.view.menu.client;

import com.google.gwt.user.client.ui.Tree;

import net.homelinux.ajay.net.ondisk.view.client.AppTree;
import net.homelinux.ajay.net.ondisk.view.client.CollectionTreeItem;
import net.homelinux.ajay.net.ondisk.view.client.CommandsMenu;
import net.homelinux.ajay.net.ondisk.view.client.NamedCommand;

/**
 * @author ajay
 *
 */
public class CollectionMenuBuilder extends FolderMenuBuilder {

  private static CollectionMenuBuilder instance;


  /**
   * @param tree
   */
  public CollectionMenuBuilder() {
    super();
  }

  public CommandsMenu makeContextMenu()
  {
    CommandsMenu contextMenu = super.makeContextMenu();
    if(contextMenu==null){
      contextMenu = new CommandsMenu();
    }
    return contextMenu;
    
  }

  protected NamedCommand getDeleteCommand() {
    return new NamedCommand("Delete Collection", null){

      public void execute() {
        System.out.println("Executing Named Command :"+ getName());
        CollectionTreeItem current = (CollectionTreeItem) getTree().getSelectedItem();
        current.removeFolderFromParent();
      }};
  }


  public static FolderMenuBuilder getInstance(AppTree tree) {
    if(instance == null){
      instance = new CollectionMenuBuilder();
    }
    return instance;
  }

}
